Skip to content

fix: reserve event cpi discriminator in dispatch#4581

Open
abhinavgautam01 wants to merge 2 commits into
otter-sec:anchor-nextfrom
abhinavgautam01:fix/4272-v2-event-discriminator-shadow
Open

fix: reserve event cpi discriminator in dispatch#4581
abhinavgautam01 wants to merge 2 commits into
otter-sec:anchor-nextfrom
abhinavgautam01:fix/4272-v2-event-discriminator-shadow

Conversation

@abhinavgautam01
Copy link
Copy Markdown

Fixes #4272

Summary

  • Dispatches the reserved event-CPI tag before user instruction discriminators.
  • Prevents a custom short discriminator like [0xe4] from shadowing the full event-CPI tag.
  • Adds a regression test showing that the overlapping short custom discriminator still dispatches normally when sent by itself.

Testing

  • rustfmt --check lang/syn/src/codegen/program/dispatch.rs tests/events/programs/events/src/lib.rs
  • git diff --check
  • cargo test -p anchor-syn
  • cargo test --manifest-path tests/events/programs/events/Cargo.toml
  • cargo test -p tests-v2 event_cpi
  • PATH="$HOME/.local/bin:$HOME/.nvm/versions/node/v20.19.0/bin:$PATH" ../../target/debug/anchor test --skip-lint from tests/events

Full tests/events result: 5 passing

@0x4ka5h
Copy link
Copy Markdown
Collaborator

0x4ka5h commented May 25, 2026

@abhinavgautam01 can you address the failed CI?

@0x4ka5h 0x4ka5h requested a review from jamie-osec May 25, 2026 14:04
@abhinavgautam01
Copy link
Copy Markdown
Author

@abhinavgautam01 can you address the failed CI?

on it...

@abhinavgautam01 abhinavgautam01 force-pushed the fix/4272-v2-event-discriminator-shadow branch from cb41a7e to 66f3a19 Compare May 25, 2026 14:33
Copy link
Copy Markdown
Collaborator

@swaroop-osec swaroop-osec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants